<?php

class PublishTemplate extends Doctrine_Template
{
    protected $_options = array('start' =>  array('name'          =>  'publish_start_at',
                                                    'alias'         =>  null,
                                                    'type'          =>  'timestamp',
                                                    'format'        =>  'Y-m-d H:i:s',
                                                    'disabled'      =>  false,
                                                    'expression'    =>  false,
                                                    'options'       =>  array('notnull' => true, 'default' => '2005-01-01 00:00:00')),
                                'end' =>  	array('name'          =>  'publish_end_at',
                                                    'alias'         =>  null,
                                                    'type'          =>  'timestamp',
                                                    'format'        =>  'Y-m-d H:i:s',
                                                    'disabled'      =>  false,
                                                    'expression'    =>  false,
                                                    'onInsert'      =>  true,
                                                    'options'       =>  array('notnull' => true,'default' => '2015-12-31 23:59:59')));



		public function setTableDefinition()
    {
        if ( ! $this->_options['start']['disabled']) {
            $name = $this->_options['start']['name'];
            if ($this->_options['start']['alias']) {
                $name .= ' as ' . $this->_options['start']['alias'];
            }
            $this->hasColumn($name, $this->_options['start']['type'], null, $this->_options['start']['options']);
        }

        if ( ! $this->_options['end']['disabled']) {
            $name = $this->_options['end']['name'];
            if ($this->_options['end']['alias']) {
                $name .= ' as ' . $this->_options['end']['alias'];
            }
            $this->hasColumn($name, $this->_options['end']['type'], null, $this->_options['end']['options']);
        }
        $this->addListener(new PublishListener($this->_options));
    }
}
